package com.mrjy.audio.bo;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Service;

import com.mrjy.audio.dao.IAudioInfoDao;
import com.mrjy.common.entity.AudioInfo;
import com.mrjy.common.entity.UserInfo;
import com.mrjy.common.util.GlobalConstant;

@Service("audioInfoBo")
public class AudioInfoBo implements IAudioInfoBo {
	
	@Resource
	private IAudioInfoDao audioInfoDao;
	

	@Override
	public Object queryPageAudio(AudioInfo info, HttpSession session) {
		Map<String, Object> map = new HashMap<String, Object>();
		UserInfo loginUser = (UserInfo) session.getAttribute(GlobalConstant.USER_INFO);
        if (null == loginUser) {
            map.put("err_code", -1);
            map.put("err_msg", "用户未登录");
            return map;
        }
        
        int total = audioInfoDao.countList(info);
        if(total > 0){
        	List<AudioInfo> list = audioInfoDao.queryList(info);
        	if(null != list && list.size() > 0){
        		map.put("err_code", 0);
				map.put("err_msg", "查询成功");
				map.put("rows", list);
				map.put("total", total);
                map.put("totalCount", total);
                return map;
        	}
        }
        
        map.put("err_code", 1);
		map.put("err_msg", "查询无数据");
        map.put("totalCount", total);
        return map;
	}
	
	

}
